package dk.itu.mobile.vo;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;

import javax.xml.bind.annotation.XmlAttribute;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlTransient;

/**
 * @author niebje
 * 
 */
@XmlRootElement(name = "task")
public class Task implements Serializable {

	private static final long serialVersionUID = 1L;

	@XmlAttribute
	public String id;
	@XmlAttribute
	public String name;
	@XmlAttribute
	public String date;
	@XmlAttribute
	public Status status;
	public String description;
	public String attendants;
//	transient private List<User> users;

	public Task() {
		// Empty constructor for marshalling
		//users = new ArrayList<User>();
	}

	public Task(String name, String id, String date, String description) {
		this.name = name;
		this.id = id;
		this.date = date;
		this.description = description;
		this.status = Status.NOT_EXECUTED;
	}

	public Task(String name, String id, String date, String description,
			List<User> users) {
		this(name, id, date, description);
		//this.users = users;
	}

//	@XmlTransient
//	public List<User> getUsers() {
//		return users;
//	}
//
//	public void setUsers(List<User> users) {
//		this.users = users;
//		attendants = "";
//		for (User item : users) {
//			attendants += item.name + ", ";
//		}
//	}

	public boolean equals(Object other) {
		if (this == other) {
			return true;
		} else if (other instanceof Task) {
			Task otherTask = (Task) other;
			if (this.id.equals(otherTask.id)) {
				return true;
			}
		}
		return false;
	}
	
	public String toString() {
		String value = "Task: \n";
		
		value += "   Id: " + id + "\n";
		value += "   name: " + name + "\n";
		value += "   date: " + date + "\n";
		value += "   status: " + status.toString() + "\n";
		value += "   description: " + description + "\n";
		value += "   attendants: " + attendants + "\n";
				
		return value;
	}
}
